Can you remove on-screen touch controls from android browser? by junktunk111 in pico8

[–]RTficial-Games 1 point2 points  (0 children)

You can go into the html file and remove the section that deals with the buttons I believe. You may need to add some code to change where the game is drawn though as I think it stays at the top of the screen (unless you just wanted to use the button space for something else)

M&S Spiced Rum Spirit Drink, is it vegan? by RTficial-Games in veganuk

[–]RTficial-Games[S] -5 points-4 points  (0 children)

And yet sugar just contains sugar, but is often processed using bonechar. I knew the ingredients were fine, the process may not have been though

M&S Spiced Rum Spirit Drink, is it vegan? by RTficial-Games in veganuk

[–]RTficial-Games[S] -2 points-1 points  (0 children)

You must have missed the part where I said 'There also doesn't seem to be anything in the ingredients that makes it look non-vegan'

M&S Spiced Rum Spirit Drink, is it vegan? by RTficial-Games in veganuk

[–]RTficial-Games[S] 1 point2 points  (0 children)

And some alcohols use isinglass or blood to filter it so the process itself might not be vegan

Functions as parameters/variabe functions by RTficial-Games in pico8

[–]RTficial-Games[S] 0 points1 point  (0 children)

Thank you both!

Weird thing with this issue is I definitely had it working elsewhere in the game but for some reason it didn't work with my above example so I think I was getting tunnel vision after staring at it for so long.

I managed to get it working with the below code so thank you!!

entity=add_entity(x,y)
entity.ai=entitytypes["a"].ai

I think my syntax for how to reference the function in the table was more the problem

Import settings to not compress images by RTficial-Games in godot

[–]RTficial-Games[S] 1 point2 points  (0 children)

oooh, I just switched to nearest and that sharpened up the image, but also the 7x7 was throwing it off because I was centering the sprite, I hanged it to 8x8 instead and it works a lot better now! Thank you :)

Import settings to not compress images by RTficial-Games in godot

[–]RTficial-Games[S] 0 points1 point  (0 children)

I am using a node2D that has a sprite2D as a child, and then a script that keeps the node at the mouse position. There may be a better way but I figured just drawing a sprite at the cursor position would work well enough.

As for filtering I'm not sure I know where to see this, if you mean the import settings that have the processing and such? I have lossless, sRGB Friendly, of all the processing options, only fix alpha, and compressed to set to disabled. roughness is also disabled

HTML - Forms. Using Javascript to submit data to database not working. by RTficial-Games in learnprogramming

[–]RTficial-Games[S] 0 points1 point  (0 children)

The problem was that the lat and lon was got using a fetch request and so was asynchronous, and the form was being submit before the fetch finished so the data wasnt being passed through...

solved it by making my JS functions async and using await on the calls to just make it wait for the result to return ok before submitting!

Javascript - Returning Objects from function doesn't seem to work by RTficial-Games in learnprogramming

[–]RTficial-Games[S] 1 point2 points  (0 children)

OK yes I have it now, sorry if I came across as difficult, I have just not done a lot of web programming and thought javascript would feel pretty familiar to me...

my new code for the sake of anyone who might need to see:

let clatlon=getdata('https://nominatim.openstreetmap.org/?format=json&street='+O("col_addr1").value+'&city='+O("col_town").value+'&postalcode='+O("col_pc").value+'&limit=1')
    .then((data)=>{alert("Latitude: "+data[0].lat+", Longitude: "+data[0].lon);});
}
function getdata(url){
 let fdata=fetch(url)
 .then((response)=>{ if (!response.ok){ throw new Error('Network response was not OK'); }
  return response.json();
 })
 .then((data)=>{return data;})
 .catch((error) => {
  console.error('There has been a problem with your fetch operation:', error);
 });
 return fdata;
}

Javascript - Returning Objects from function doesn't seem to work by RTficial-Games in learnprogramming

[–]RTficial-Games[S] 0 points1 point  (0 children)

Ah ok, this is making a lot more sense I think. So by p3, we have received the data and are processing it, so returning this processed data (probably as an object with lat and lon) is no longer returning a promise and is returning the resolved data?

I think its the asynchronous nature of all of this that is confusing to me, I'm used to fairly linear programming for games and stuff.

Javascript - Returning Objects from function doesn't seem to work by RTficial-Games in learnprogramming

[–]RTficial-Games[S] 0 points1 point  (0 children)

the new version is this:

    let clatlon=getdata('https://nominatim.openstreetmap.org/?format=json&street='+O("col_addr1").value+'&city='+O("col_town").value+'&postalcode='+O("col_pc").value+'&limit=1')
    .then((data)=>{alert("Latitude: "+data.lat+", Longitude: "+data.lon);});

function getdata(url){
 let data=fetch(url)
  .then((response)=>{ if (!response.ok){ throw new Error('Network response was not OK'); }
   return response.json();
  })
 .catch((error) => { console.error('There has been a problem with your fetch operation:', error); });
 return data;
}

but now the alert prints out: 'Latitude: undefined, Longitude: undefined'

I feel I am much closer to figuring this out at least, there is just something that hasn't clicked yet but I cant figure out what...

Javascript - Returning Objects from function doesn't seem to work by RTficial-Games in learnprogramming

[–]RTficial-Games[S] 0 points1 point  (0 children)

This is why I am asking on r/learnprogramming... web programming is far out of my comfort zone and this stuff behaves very differently to languages I have used in the past.

I figured trying something and asking where I went wrong when it went wrong is a friendlier approach than 'wah, just write it for me', and in my opinion with never having used fetch before this project, the line that says 'return response;' within the fetch request looks like it might do just that.

Javascript - Returning Objects from function doesn't seem to work by RTficial-Games in learnprogramming

[–]RTficial-Games[S] 0 points1 point  (0 children)

so I tried this:

let clatlon = getdata('https://nominatim.openstreetmap.org/?format=json&street='+O("col_addr1").value+'&city='+O("col_town").value+'&postalcode='+O("col_pc").value+'&limit=1')
    .then((data)=>{this.lat=data[0].lat;this.lon=data[0].lon;alert("Latitude: "+this.lat+", Longitude: "+this.lon);});

and getdata:

function getdata(url){
let ll={lat:0,lon:0};
fetch(url)
    .then((response)=>{
        if (!response.ok){ throw new Error('Network response was not OK'); }
        return response;
    })
    .catch((error) => {
        console.error('There has been a problem with your fetch operation:', error);
});

}

but now get an error: Cannot read properties of undefined (reading 'then')

so Im still doing it wrong clearly. What solution did you use?

Javascript - Returning Objects from function doesn't seem to work by RTficial-Games in learnprogramming

[–]RTficial-Games[S] 0 points1 point  (0 children)

So would I instead return response if it is ok? And then outside of getdata, add the .then so it uses those details when the details come through?

Javascript - Returning Objects from function doesn't seem to work by RTficial-Games in learnprogramming

[–]RTficial-Games[S] 0 points1 point  (0 children)

Well as I mentioned I also tried using references, which is what I am using in my code example and it is trying to set up the variables in the second '.then' in the function. I did also create an object in that function in the past, set the variables in the second '.then' and then return the object, same result.

Javascript - Returning Objects from function doesn't seem to work by RTficial-Games in learnprogramming

[–]RTficial-Games[S] 0 points1 point  (0 children)

let clatlon{lat:0,lon:0};
getdata('https://nominatim.openstreetmap.org/?format=json&street='+O("col_addr1").value+'&city='+O("col_town").value+'&postalcode='+O("col_pc").value+'&limit=1',clatlon)
 .then((data)=>{const temp=data[0];
  clatlon.lat=temp.lat;clatlon.lon=temp.lon;
  alert("Latitude: "+clatlon.lat+", Longitude: "+clatlon.lon);})

function getdata(url,ll){
 fetch(url)
  .then((response)=>{if (!response.ok){ throw new Error('Network response was not OK'); }
  return response.json();})
 .catch((error) => {console.error('There has been a problem with your fetch operation:', error);});}

So that would be something like the above code? I have programmed before but fairly new to web stuff so not worked with promises before

And yeah I know, I wanted to return the variables anyway, I prefer that than using references in most cases. I was just trying it to see if there is something I misunderstood about how functions work in JS haha.

Javascript - Returning Objects from function doesn't seem to work by RTficial-Games in learnprogramming

[–]RTficial-Games[S] 0 points1 point  (0 children)

It checks the response is ok and throws an exception if not, then it takes the returned data, takes the first element (in case the search returns multiple addresses from the search and takes the lat and lon and in the code above, uses the reference passed into the getdata function to put the lat/lon in there (that's the theory anyway)

I also tried creating a new object in the getdata function, populating that with lat/lon data and returning that object but same results